package system;
import java.sql.*;
public class finishTest{
	String test_id;
	
	public void setTest_id(String str){
		try{
			byte b[]=str.getBytes("ISO-8859-1");
            test_id=new String(b);
		} catch(Exception e){}
	}
	public String getTest_id(){
		return test_id;
	}
	
	public boolean getUpdate(){
		boolean  update=false;
		String updateCondition="update testing set isFinished=1 where test_id='"+test_id+"';insert into student_test values('student','"+test_id+"',0,0)";
		Connection con;
	    Statement sql;
	    try{
	    	Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	    	}
	    catch(Exception e){}
   
    try{
		String uri = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test_system";
		String user = "sa";
		String password = "sa";
		con=DriverManager.getConnection(uri,user,password);
		sql=con.createStatement();
		int m=sql.executeUpdate(updateCondition);
		if(m!=0){
			update=true;			
		}
		con.close();
	}
	catch(SQLException e1){update=false;}
	return update;
	}
}